﻿@model Matrix.MaKaYunShang.Model.MatrixCloudProjectInfo
@{
    ViewBag.Title = "添加项目";
    ViewBag.PathToBtn = "/SysConfig/ProjectInfo";
    ViewBag.TextBtn = "返回至列表";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                添加项目
            </div>
            <div class="panel-body">
                <div class="row">
                    @using (Html.BeginForm("ProjectInfoCreate", "SysConfig", FormMethod.Post, new { id = "frmCreate", enctype = "multipart/form-data" }))
                    {
                        @Html.AntiForgeryToken()
                        @Html.ValidationSummary(true)
                        <div class="col-lg-12">
                            <fieldset>
                          
                                <div class="form-group col-md-6">
                                    <label>项目名称</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.PjName, new { @class = "form-control", placeholder = "项目名称" })
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label>Code</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.PjCode, new { @class = "form-control", placeholder = "Code", })
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label>McId</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.PjMcId, new { @class = "form-control", placeholder = "McId" })
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label>Secret</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.PjSecret, new { @class = "form-control", placeholder = "Secret" })
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <button id="btnSave" type="button" class="btn btn-primary">确认并保存</button>
                                    <button id="btnReset" type="reset" class="btn btn-outline btn-primary">清空设置</button>
                                </div>
                            </fieldset>
                        </div>
                    }
                </div>
            </div>
        </div>
    </div>
</div>
@section javascript{
    <script type="text/javascript">
        $(function () {
            $("#frmCreate").validate({
                rules: {
                    PjName: { required: true }
                    //PjCode: { required: true }
                    //, PjName: { required: true }
                },
                messages: {
                    PjName: { required: "请填写行业名称" },
                    PjCode: { required: "请填写Code" }
                },
                submitHandler: function (form) {
                  //  form.submit();
                }
            });
            
            $("#btnSave").click(function() {
                if ($("#frmCreate").valid()) {
                    $.ajax({
                        type: 'post',
                        async: false,
                        url: '/SysConfig/ProjectInfoCreate',
                        data: $('#frmCreate').serialize(),
                        success: function(result) {
                            if (result.Status) {
                                $("#hidId").val(result.Message);
                                alertify.success("添加成功");
                                setTimeout(function () { location.href = "/SysConfig/ProjectInfo/"; }, 1000);
                            } else {
                                alertify.error(result.Message);
                            }

                        }
                    });
                }
            });
        });
    </script>
}